/**
 * 
 */
var	GONOGO_APP = 0;
var	DECISION_APP = 1;
var	WIKI_APP = 2;
var	FOP_APP = 3; 
var	LOG_APP = 4;
var	TM_APP = 5;
var	MOBILITY_APP = 6;

var ENABLED = 1;
var DISABLED = 0;

$(function(){

	  //Appel du script php
	$.ajax({
	type: "POST",
	url: "/Server/sessions.php",
	data: {
		maFonction : 'startSession'
	},

	success: function(data){	
		//alert("Toto yiiiihah!");
		//alert(data);
		//var pathname = window.location.pathname;
		var pathname = $(location).attr('href');

		//Cas Go-No Go
		if(pathname.search("GoNoGo")!=-1) {
			
			if(data[GONOGO_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		} else if (pathname.search("Decision") != -1) {
			if(data[DECISION_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		} else if (pathname.search("Wiki") != -1) {
			if(data[WIKI_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		} else if (pathname.search("FOP") != -1) {
			if(data[FOP_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		} else if (pathname.search("Log") != -1) {
			if(data[LOG_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		} else if (pathname.search("TM") != -1) {
			if(data[TM_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		} else if (pathname.search("MobilityPage") != -1) {
			if(data[MOBILITY_APP]==DISABLED) {
				window.location = "http://localhost/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
			}
		}
		$.get("/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/panel.html", function(data){
			$('#panel-wrapper').html(data).trigger("create");
		});
		
		$.get("/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/header.html", function(data){
			$('#header').html(data).trigger("create");
		});
		
		$.get("/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/footer.html",function(data){
			$('#footer').html(data).trigger("create");
		});

	},

	error: function(msg, string) {
		//alert("Erreur : "+string);
		//window.location = "/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/connexionPage.html";
		window.location = "/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/forbidden.html";
	}
	});

	
	
	
});